<template>
  <div class="person">
    <h1>中国</h1>
    <h2 ref="title2">北京</h2>
    <h3>尚硅谷</h3>
    <button @click="showLog">点我输出 h2 这个元素</button>
  </div>
</template>

<script setup lang="ts">
import {ref} from 'vue'

// ref 创建一个 title2，用于存储 ref 标记的内容
const title2 = ref<HTMLElement | null>(null)

const a = ref<number>(0)
const b = ref<number>(1)
const c = ref<number>(2)

const showLog = () => {
  console.log(title2.value)
}

// expose 暴露数据，让外部可以访问
defineExpose({a, b, c})
</script>

<!-- scoped 局部样式选择器，只影响当前页面 -->
<style scoped lang="scss">
.person {
  background-color: skyblue;
  box-shadow: 0 0 10px;
  border-radius: 10px;
  padding: 20px;

  button {
    margin: 0 5px;
  }

  li {
    font-size: 20px;
  }
}
</style>
